<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script>
    var date = new Date();
    console.log(date);
    console.log(date.getFullYear());//放回年份
    console.log(date.getMonth() + 1);//返回月份如果需要当前月份需要加11
    console.log(date.getDay());//返回星期
    console.log(date.getDate());//返回几号
    console.log(date.getHours());//返回小时
    console.log(date.getMinutes());//返回分
    console.log(date.getSeconds());//返回秒
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var dates = date.getDate();
    var arr = ['星期天','星期一','星期二','星期三','星期四','星期五','星期六'];
    var day = date.getDay();
    console.log(year+'年'+month+'月'+dates+'日 '+arr[day]);
    var date1 = new  Date();
    console.log(date1.valueOf());//返回现在到1970.1.1的总毫秒   时间戳
    console.log(date1.getTime());
    function conutDown(time) {
        var nowTime = +new Date();  //返回当前时间戳
        var inputTime = +new Date(time);    //返回用户输入的时间戳
        var times = (inputTime - nowTime) / 1000;   //times是剩余的秒数
        var d = parseInt(times / 60 / 60 / 24); //天
        d = d < 10 ? '0' + d : d;   //自动补0
        var h = parseInt(times / 60 / 60 % 24); //时
        h = h < 10 ? '0' + h : h;
        var m = parseInt(times / 60 % 60);  //分
        m = m < 10 ? '0' + m : m;
        var s = parseInt(times % 60);   //秒
        s = s < 10 ? '0' + s : s;
        return d+'天'+h+'时'+m+'分'+s+'秒';
    }
    console.log(conutDown('2019-9-2 14:00:00'));
</script>
<body>

</body>
</html>